package br.com.hmcontabilidade.onlinev3.view;

import javax.inject.Inject;

import br.com.hmcontabilidade.onlinev3.business.CategoriaOcorrenciaBC;
import br.com.hmcontabilidade.onlinev3.domain.CategoriaOcorrencia;
import br.gov.frameworkdemoiselle.annotation.PreviousView;
import br.gov.frameworkdemoiselle.stereotype.ViewController;
import br.gov.frameworkdemoiselle.template.AbstractEditPageBean;
import br.gov.frameworkdemoiselle.transaction.Transactional;

@ViewController
@PreviousView("/categoriaocorrencia_list.xhtml")
public class CategoriaOcorrenciaEditMB extends AbstractEditPageBean<CategoriaOcorrencia, Long> {

	private static final long serialVersionUID = 1L;

	@Inject
	private CategoriaOcorrenciaBC categoriaOcorrenciaBC;

	@Override
	@Transactional
	public String delete() {
		this.categoriaOcorrenciaBC.delete(getId());
		return getPreviousView();
	}

	@Override
	@Transactional
	public String insert() {
		this.categoriaOcorrenciaBC.insert(getBean());
		return getPreviousView();
	}

	@Override
	@Transactional
	public String update() {
		this.categoriaOcorrenciaBC.update(getBean());
		return getPreviousView();
	}

	@Override
	protected void handleLoad() {
		setBean(this.categoriaOcorrenciaBC.load(getId()));
	}

}
